
<?php

//判断
if (isset($_POST['username'])&&isset($_POST['content'])&&$_POST['username']&&$_POST['content']){
    //引进存数据的数组
    $re = include 'xuyuanchang.php';
//引进各种函数
    include 'functions.php';
    //设置东八地区的时间
    date_default_timezone_set('PRC');
//创建一个数组，把提交的数据存进来
    $arr = array(
        'username'=>$_POST['username'],
        'content'=>$_POST['content'],
        'time'=>date('y/m/d h:i:s')
    );
//让刚刚写的数组和引进来的数组合并
    $re = C($re,$arr);
//把数组转成字符串
    $configstr = var_export($re,true);
//将新的配置项写入到配置文件中
    $str = "<?php\n\r return ".$configstr."\n\r ?>";
//把转化成字符串的数组再存会原本的PHP文件里面
    file_put_contents('xuyuanchang.php',$str);

}



?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
    <title>cenyansen留言板</title>
    <link rel="stylesheet" href="./Css/index.css"/>
    <script type="text/javascript" src='./Js/jquery-1.7.2.min.js'></script>
    <script type="text/javascript" src='./Js/index.js'></script>
</head>
<body>
<div id='top'>
    <span id='send'></span>
</div>
<div id='main'>
    <?php
    $er = include 'xuyuanchang.php';
    foreach($er as $k=>$v){
        echo " 
    <dl class='paper a".mt_rand(1,5)."'>
        <dt>
            <span class='username'>".$er[$k]['username']."</span>

            <a href='edit.php?id=$k' class='num'>编辑</a>
        </dt>
        <dd class='content'>".$er[$k]['content']."</dd>
        <dd class='bottom'>
            <span class='time'>".$er[$k]['time']."</span>
            <a href='sanchu.php?id=$k' class='close'></a>
        </dd>
    </dl>";
    }
    ?>
</div>

<div id='send-form'>
    <p class='title'><span>留下你路过的证据</span><a href="" id='close'></a></p>
    <form action="" name='wish' method="post">
        <p>
            <label for="username">昵称：</label>
            <input type="text" name='username' id='username'/>
        </p>
        <p>
            <label for="content">留言：(您还可以输入&nbsp;<span id='font-num'>50</span>&nbsp;个字)</label>
            <textarea name="content" id='content'></textarea>
        <div id='phiz'>
            <img src="./Images/phiz/zhuakuang.gif" alt="抓狂"/>
            <img src="./Images/phiz/baobao.gif" alt="抱抱"/>
            <img src="./Images/phiz/haixiu.gif" alt="害羞"/>
            <img src="./Images/phiz/ku.gif" alt="酷"/>
            <img src="./Images/phiz/xixi.gif" alt="嘻嘻"/>
            <img src="./Images/phiz/taikaixin.gif" alt="太开心"/>
            <img src="./Images/phiz/touxiao.gif" alt="偷笑"/>
            <img src="./Images/phiz/qian.gif" alt="钱"/>
            <img src="./Images/phiz/huaxin.gif" alt="花心"/>
            <img src="./Images/phiz/jiyan.gif" alt="挤眼"/>
        </div>
        </p>
        <input type="submit" id="send-btn" value=""
               style="display: block;width: 130px;height: 50px;background: url(Images/send-btn.png) no-repeat center center;cursor: pointer;float: right;margin: 10px;border: 1px solid #FFF">
    </form>
</div>
<!--[if IE 6]>
<script type="text/javascript" src="./Js/iepng.js"></script>
<script type="text/javascript">
    DD_belatedPNG.fix('#send,#close,.close', 'background');
</script>
<![endif]-->
</body>
</html>